"""MxOnline URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.views.generic import TemplateView
from apps.users.views import LoginView, LogoutView, RegisterView
from apps.organizations.views import OrgView
import xadmin
from django.conf.urls import url, include
from django.views.static import serve
from MxOnline.settings import MEDIA_ROOT
from apps.operations.views import IndexView

urlpatterns = [
    # path('admin/', admin.site.urls),
    path('xadmin/', xadmin.site.urls),
    path('', IndexView.as_view(), name='index'),
    path('login/', LoginView.as_view(), name='login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('register/', RegisterView.as_view(), name='register'),
    url(r'^captcha/', include('captcha.urls')),

    #机构相关页面
    url(r'^org/', include(('apps.organizations.urls', "organizations"), namespace="org")),

    #课程相关页面
    url(r'^course/', include(('apps.courses.urls', "organizations"), namespace="course")),

    #配置上传文件的访问url
    url(r'^media/(?P<path>.*)$', serve, {"document_root":MEDIA_ROOT}),
    # url(r'^static/(?P<path>.*)$', serve, {"document_root":STATIC_ROOT}),

    # 用户相关操作
    url(r'^op/', include(('apps.operations.urls', "organizations"), namespace="op")),

    # 用户个人中心
    url(r'^users/', include(('apps.users.urls', "users"), namespace="users")),
]
#1.CBV(class base view有利于代码的重用) FBV(function base view)